package com.ruoyi.system.controller.sales;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.MaterialExp;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.sample.SamSample;
import com.ruoyi.system.service.sample.ISamSampleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

@Slf4j
@RestController
@RequestMapping("/system/sample")
public class SampleCtr extends BaseController {
    @Autowired
    ISamSampleService samSampleService;

    @GetMapping("/selectSample")
    public SamSample selectSample(SamSample samSample) {
        return samSampleService.getById(samSample.getSpId());
    }

    @PostMapping
    public void insertSample(SamSample samSample) {
        samSample.setCreateDate(LocalDateTime.now());
        samSample.setCreateStaffId(SecurityUtils.getUserId());
        samSample.setCreateStaffName(SecurityUtils.getUsername());
        samSampleService.save(samSample);
    }

    @PutMapping
    public void updateSample(SamSample samSample) {
        LambdaUpdateWrapper<SamSample> queryWrapper = new UpdateWrapper<SamSample>().lambda();
//        queryWrapper.set(SamSample::getSpNo, samSample.getSpNo())
//                .set(SamSample::get, samSample.getMatName())
//                .set(SamSample::getType, samSample.getType())
//                .set(SamSample::getClName, samSample.getClName())
//                .set(SamSample::getCustMatName, samSample.getCustMatName())
//                .set(SamSample::getCurId, samSample.getCurId())
//                .set(SamSample::getEngColor, samSample.getEngColor())
//                .set(SamSample::getEngName, samSample.getEngName())
//                .set(SamSample::getImagePath, samSample.getImagePath())//图片单独处理？
//                .set(SamSample::getMcId, samSample.getMcId())
//                .set(MaterialExp::getModifyDate,LocalDateTime.now())
//                .set(MaterialExp::getModifyStaffId,SecurityUtils.getUserId())
//                .set(MaterialExp::getModifyStaffName,SecurityUtils.getUsername())
//                .eq(SamSample::getMatId, samSample.getMatId());
    }

}
